home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-11 | 1.6 KB | 89 lines | [TEXT/CWIE] |
- unit MyGrowZones;
-
- interface
-
- uses
- Types;
-
- procedure StartupGrowZones;
- procedure ConfigureGrowZones(size: longint);
- function MemoryCritical: boolean;
- function EnoughSpace (total, contig: longint): boolean;
- procedure IdleGrowZone; { Called by IdleStartup, you can call it yourself }
-
- implementation
-
- uses
- Memory, OSUtils,
- PreserveA5, MyCallProc, MyStartup;
-
- var
- gzh: handle;
- gz_size: longINt;
-
- function MyGrowZone (size: longint): longint;
- var
- saved_A5:Ptr;
- begin
- size:=size; { UNUSED! }
- saved_A5 := SetPreservedA5;
- if gzh <> nil then begin
- MyGrowZone := GetHandleSize(gzh);
- DisposeHandle(gzh);
- gzh := nil;
- end else begin
- MyGrowZone := 0;
- end;
- RestoreA5(saved_A5);
- end;
-
- function MemoryCritical: boolean;
- begin
- MemoryCritical := gzh = nil;
- end;
-
- function EnoughSpace (total, contig: longint): boolean;
- var
- t, c: longint;
- begin
- PurgeSpace(t, c);
- EnoughSpace := not MemoryCritical & (t >= total) & (c >= contig);
- end;
-
- procedure IdleGrowZone;
- begin
- if gzh = nil then begin
- gzh := NewHandle(gz_size);
- end;
- end;
-
- procedure ConfigureGrowZones(size: longint);
- begin
- StartupGrowZones;
- gz_size := size;
- end;
-
- function InitGrowZone(var msg: integer): OSStatus;
- begin
- msg := msg; { Unused }
- SetGrowZone(NewProc(@MyGrowZone,uppPascal44ProcInfo));
- gzh := nil;
- IdleGrowZone;
- InitGrowZone := noErr;
- end;
-
- procedure FinishGrowZone;
- begin
- if gzh <> nil then begin
- DisposeHandle(gzh);
- gzh := nil;
- end;
- end;
-
- procedure StartupGrowZones;
- begin
- StartupPreserveA5;
- SetStartup(InitGrowZone, IdleGrowZone, 30, FinishGrowZone);
- end;
-
- end.